package org.dragonnova.business.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.dragonnova.business.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.base.pub.web.BaseController;

@Controller
public class PageController extends BaseController {
	
	@RequestMapping("/index")
	public String index(){
		return "lable/index";
	}
	@RequestMapping("/login")
	public String login(){
		return "login";
	}
	
	@RequestMapping("/logout") 
	public void login(HttpSession session,HttpServletRequest request,HttpServletResponse resp) throws Exception {
		session.invalidate();
		resp.sendRedirect("login.html");
	}
	
	/**
	 * 曲线图
	 * @return
	 */
	@RequestMapping("/diagram")
	public String diagram(){
		return "diagram/diagram";
	}
	/**
	 * 跳转jsp页面
	 * @return
	 */
	@RequestMapping("/page")
	public ModelAndView page(HttpServletResponse resp,String jsp){
		return new ModelAndView(jsp);
	}
	/**
	 * 跳转lable/index页面
	 * @return
	 */
	@RequestMapping("/lable")
	public String lableIndex(){
		return "lable/index";
	}
	/**
	 * 跳转lable/details页面
	 * @return
	 */
	@RequestMapping("/details")
	public String lableDetails(){
		return "lable/details";
	}
	/**
	 * 跳转lable/search页面
	 * @return
	 */
	@RequestMapping("/search")
	public String lableSearch(){
		return "lable/search";
	}
	/**
	 * 跳转添加标签页面
	 * @return
	 */
	@RequestMapping("/addLable")
	public String addLable(){
		return "lable/addLable";
	}
	/**
	 * 跳转路由器页面
	 * @return
	 */
	@RequestMapping("/router")
	public String router(){
		return "router/router";
	}
	/**
	 * 跳转路由器详情页面
	 * @return
	 */
	@RequestMapping("/routerDetails")
	public String routerDetails(){
		return "router/routerDetails";
	}
	/**
	 * 跳转用户详情页面
	 * @return
	 */
	@RequestMapping("/user")
	public String user(HttpSession session){
		User user = getLoginUser(session);
		if(user!=null&&isAdmin(user)){
			return "user/userlist";
		}else{
			return "user/user";
		}
	}
	/**
	 * 跳转编辑页面
	 * @return
	 */
	@RequestMapping("/editUser")
	public String editUser(){
		return "user/editUser";
	}
	/**
	 * 跳转设置页面
	 * @return
	 */
	@RequestMapping("/setting")
	public String settingLable(){
		return "setting/setting";
	}
	/**
	 * 跳转扫码添加编辑页面
	 * @return
	 */
	@RequestMapping("/codeAddLable")
	public String codeAddLable(){
		return "lable/codeAddLable";
	}
}
